<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Test to make sure we return correct text-decoration state.
// Note that "text-decoration: none" SHOULD NOT cancel text decorations.

function editable(sample) {
  return `<div contenteditable>${sample}</div>`;
}

function testIt(command_name, input, expected, description) {
  selection_test(
    editable(input),
    seleciton => {
      assert_equals(seleciton.document.queryCommandState(command_name),
                    expected, `queryCommandState('${command_name}')`);
    },
    editable(input),
    description);
}

// underline
testIt('underline',
      '<u><b><i><span>^hello world|</span></i></b></u>',
      true,
      'underline-1');
testIt('underline',
      '<b><i><u><span>^hello world|</span></u></i></b>',
      true,
      'underline-2');
testIt('underline',
      '<b><i><span style="text-decoration: underline;">^hello world|</span></i></b>',
      true,
      'underline-3');
testIt('underline',
       '<span style="text-decoration: underline;"><em>^hello world|</em></span>',
       true,
       'underline-4');
testIt('underline',
       '<u><b><i><span style="text-decoration:none">^hello world|</span></i></b></u>',
       true,
       'underline-5');

// strike-through
testIt('strikeThrough',
       '<b><i><span>^hello world|</span></i></b>',
       false,
       'strike-through-1');
testIt('strikeThrough',
       '^<s><b><i><span>hello world</span></i></b></s>|',
       true,
       'strike-through-2');
testIt('strikeThrough',
       '<b><i><s><span>^hello world|</span></s></i></b>',
       true,
       'strike-through-3');
testIt('strikeThrough',
       '<b><i><span style="text-decoration: line-through;">^hello world|</span></i></b>',
       true,
       'strike-through-4');
testIt('strikeThrough',
       '<span style="text-decoration: line-through;"><em>^hello world|</em></span>',
       true,
       'strike-through-5');
testIt('strikeThrough',
       '<s><b><i><span style="text-decoration:none">^hello world|</span></i></b></s>',
       true,
       'strike-through-6');
</script>
